$(init);

function init() {
    $('body').on('click', 'ons-button#guide-real', function () { navPushPage('/mobile-views/_me/real-name.html') })
             .on('click', 'ons-button#guide-tb', function () { navPushPage('/mobile-views/_me/bind-tb.html') })
             .on('click', 'ons-tab#home', function () { initNoticeList(); });
    initNoticeList();
}

function initNoticeList() {
    promiseTmpl('GET', '/mobile-tmpl/notice.tmpl', '/notice_list', null, cbListNotice);
}

function cbListNotice(r, e) {
    var ret = e;
    console.log(ret);
    $('ons-page#homepage div.page__content').html('');
    $('ons-page#homepage div.page__content').append($.templates(r).render(ret, rdHelper));
    showGuide();
}

function showGuide() {
    // 全部绑定隐藏
    if(parseInt(cookie('approveState')) === 1 && parseInt(cookie('taobaoList')[0].approve) === 1) {
        $('ons-card#new-guide').css('display', 'none');
    }
    else {
        $('ons-card#new-guide').css('display', 'block');
    }

    // 绑定哪个隐藏哪个
    if(parseInt(cookie('approveState')) === 1) {
        $('ons-button#guide-real').attr("disabled","true");
    }
    if(cookie('taobaoList').length > 0 && parseInt(cookie('taobaoList')[0].approve) === 1){
        $('ons-button#guide-tb').attr("disabled","true");
    }
}